import Vue from "vue";
import VueRouter from "vue-router";
import Index from "@/views/index.vue";
import ClassInd from "@/views/class.vue";
import Order from "@/views/order.vue";
import User from "@/views/user.vue";
Vue.use(VueRouter);

const routes = [
  {
   path:'/',
   redirect: '/index'
  },
  {
    path:'/index',
    component: Index
  },
  {
    path:'/class',
    component: ClassInd
  },
  {
    path:'/order',
    component: Order
  },
  {
    path:'/user',
    component: User
  },
];

const router = new VueRouter({
  routes,
});
const isLogin = false
router.beforeEach((to, from, next) => {
  if(to.path === '/user'&& !isLogin ) {
    alert("未登入")
    next('/')
  }else{
    next()
  }
})
export default router;
